package com.wisdudu.blank.ui.user;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wisdudu.blank.R;
import com.wisdudu.blank.databinding.FragmentUserinfoSetBinding;
import com.wisdudu.frame.base.BaseFragment;
import com.wisdudu.blank.support.rxbus.RxBusFlag;

/**
 * Created by ypp on 2016/10/19.
 */
public class UserInfoSetFragment extends BaseFragment {
    private UserInfoSetVM userInfoSetVM;

    public static BaseFragment newIntance(String uid) {
        Bundle bundle = new Bundle();
        bundle.putString("uid", uid);
        UserInfoSetFragment fragment = new UserInfoSetFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected View initBinding(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        FragmentUserinfoSetBinding mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_userinfo_set, container, false);
        userInfoSetVM = new UserInfoSetVM(this, mBinding, getArguments().getString("uid"));
        mBinding.setViewModel(userInfoSetVM);
        return mBinding.getRoot();
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initToolbar(getToolbar(), "完善个人资料");
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null && requestCode == 100 && resultCode == 100) {
            userInfoSetVM.birthday.set(data.getStringExtra(RxBusFlag.SELECT_YMD));
        }
    }
}